#include "lolevel.h"
#include "platform.h"
#include "core.h"

static long *nrflag = (long*)0xC2E4;

#include "../../../generic/capt_seq.c"

void __attribute__((naked,noinline)) sub_FFEABF20_my(long p)
{
    asm volatile (
                "STMFD   SP!, {R4,LR}\n"    
                "MOV     R4, R0\n"          
                "SUB     SP, SP, #0xC\n"    
                "BL      sub_FFEAC990\n"    
                "MVN     R1, #0\n"          
                "BL      sub_FFEBD0F4\n"  
                "MOV     R0, #0x8A\n"       
                "ADD     R1, SP, #4\n"      
                "MOV     R2, #4\n"          
                "BL      sub_FFC0BC94\n"    
                "TST     R0, #1\n"          
                "BEQ     loc_FFEABF60\n"    
                "MOV     R1, #0x1D0\n"      
                "LDR     R0, =0xFFEABDA4\n" 
                "ADD     R1, R1, #2\n"      
                "BL      sub_FFECA7B0\n"     
"loc_FFEABF60:\n"                           
                "LDR     R3, =0xA5740\n"    
                "LDR     R2, =0xA5800\n"    
                "LDR     R0, [R3,#0x74]\n"  
                "LDRSH   R1, [R2,#0xE]\n"   
                "BL      sub_FFDEF83C\n"    
                "MOV     R0, R4\n"          
                "BL      sub_FFEABD28\n"    
                "BL      wait_until_remote_button_is_released\n"  
                "BL      capt_seq_hook_set_nr\n"
                "LDR     R3, =0xC2E8\n"     
                "LDR     R0, [R3]\n"

                "B       sub_FFEABF84\n"
    );
}

void __attribute__((naked,noinline)) sub_FFEA8DDC_my(long p)
{
    asm volatile (
                "STMFD   SP!, {R4,LR}\n"    
                "LDR     R4, [R0,#0xC]\n"   
                "LDR     R3, [R4,#8]\n"     
                "ORR     R3, R3, #1\n"      
                "STR     R3, [R4,#8]\n"     
                "MOV     R0, #2\n"          
                "BL      sub_FFE89D74\n"    
                "BL      sub_FFEA98D0\n"    
                "MOV     R0, R4\n"          
                "BL      sub_FFEAAA24\n"    
                "TST     R0, #1\n"          
                "MOV     R2, R4\n"          
                "MOV     R1, #1\n"          
                "BEQ     loc_FFEA8E1C\n"    
                "LDMFD   SP!, {R4,LR}\n"    
                "B       sub_FFEA75A4\n"    
"loc_FFEA8E1C:\n"                           
                "BL      sub_FFC15B00\n"    
                "BL      sub_FFC0BE90\n"    
                "STR     R0, [R4,#0x14]\n"  
                "MOV     R0, R4\n"          
                "BL      sub_FFEABE08\n"    
                "BL      sub_FFEAC7FC\n"    
                "MOV     R0, R4\n"          
                "BL      sub_FFEABF20_my\n"    
                "BL      capt_seq_hook_raw_here\n"
                "MOV     R1, #1\n"          
                "MOV     R2, R4\n"          
                "BL      sub_FFEA75A4\n"    
                "BL      sub_FFEAC29C\n"    
                "CMP     R0, #0\n"          
                "LDRNE   R3, [R4,#8]\n"     
                "ORRNE   R3, R3, #0x2000\n" 
                "STRNE   R3, [R4,#8]\n"     
                "LDMFD   SP!, {R4,PC}\n"    
    );
}

void __attribute__((naked,noinline)) capt_seq_task()
{
	asm volatile (
                "STMFD   SP!, {R4,LR}\n"    
                "SUB     SP, SP, #4\n"      
                "MOV     R4, SP\n"          
                "B       loc_FFEA9360\n"    


"loc_FFEA91F4:\n"                           
                "LDR     R2, [SP]\n"        
                "LDR     R3, [R2]\n"        
                "MOV     R0, R2\n"          
                "CMP     R3, #0x16\n"       
                "LDRLS   PC, [PC,R3,LSL#2]\n" 
                "B       loc_FFEA9334\n"    

                ".long loc_FFEA9268\n"
                ".long loc_FFEA9274\n"
                ".long loc_FFEA927C\n"
                ".long loc_FFEA9290\n"
                ".long loc_FFEA9288\n"
                ".long loc_FFEA9298\n"
                ".long loc_FFEA92A0\n"
                ".long loc_FFEA92AC\n"
                ".long loc_FFEA92B4\n"
                ".long loc_FFEA92C0\n"
                ".long loc_FFEA92C8\n"
                ".long loc_FFEA92D0\n"
                ".long loc_FFEA92D8\n"
                ".long loc_FFEA92E0\n"
                ".long loc_FFEA92E8\n"
                ".long loc_FFEA92F4\n"
                ".long loc_FFEA92FC\n"
                ".long loc_FFEA9304\n"
                ".long loc_FFEA930C\n"
                ".long loc_FFEA9318\n"
                ".long loc_FFEA9324\n"
                ".long loc_FFEA932C\n"
                ".long loc_FFEA9348\n"


"loc_FFEA9268:\n"                           
                                        
                "BL      sub_FFEA98E4\n"    
                "BL      shooting_expo_param_override\n"  // +
                "BL      sub_FFEA7098\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA9274:\n"                           
                                        
                "BL      sub_FFEA8DDC_my\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA927C:\n"                           
                                        
                "MOV     R0, #1\n"          
                "BL      sub_FFEA9AEC\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA9288:\n"                           
                                        
                "BL      sub_FFEA9448\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA9290:\n"                           
                                        
                "BL      sub_FFEA98B0\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA9298:\n"                           
                                        
                "BL      sub_FFEA98C0\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92A0:\n"                           
                                        
                "BL      sub_FFEA99DC\n"    
                "BL      sub_FFEA7098\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92AC:\n"                           
                                        
                "BL      sub_FFEA8EC0\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92B4:\n"                           
                                        
                "BL      sub_FFEA9A50\n"    
                "BL      sub_FFEA7098\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92C0:\n"                           
                                        
                "BL      sub_FFEA98B0\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92C8:\n"                           
                                        
                "BL      sub_FFEAB158\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92D0:\n"                           
                                        
                "BL      sub_FFEAB32C\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92D8:\n"                           
                                        
                "BL      sub_FFEAB3C0\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92E0:\n"                           
                                        
                "BL      sub_FFEAB4BC\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92E8:\n"                           
                                        
                "MOV     R0, #0\n"          
                "BL      sub_FFEAB728\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92F4:\n"                           
                                        
                "BL      sub_FFEAB8FC\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA92FC:\n"                           
                                        
                "BL      sub_FFEAB998\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA9304:\n"                           
                                        
                "BL      sub_FFEABA58\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA930C:\n"                           
                                        
                "MOV     R0, #1\n"          
                "BL      sub_FFEAB728\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA9318:\n"                           
                                        
                "BL      sub_FFEA9C48\n"    
                "BL      sub_FFEA8D00\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA9324:\n"                           
                                        
                "BL      sub_FFEAB5FC\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA932C:\n"                           
                                        
                "BL      sub_FFEAB658\n"    
                "B       loc_FFEA9344\n"    


"loc_FFEA9334:\n"                           
                "MOV     R1, #0x4C0\n"      
                "LDR     R0, =0xFFEA8B5C\n" 
                "ADD     R1, R1, #1\n"      
                "BL      sub_FFECA7B0\n"     

"loc_FFEA9344:\n"                           
                                        
                "LDR     R2, [SP]\n"        

"loc_FFEA9348:\n"                           
                                        
                "LDR     R3, =0x7EEC0\n"    
                "LDR     R1, [R2,#4]\n"     
                "LDR     R0, [R3]\n"        
                "BL      sub_FFEBCF58\n"    
                "LDR     R0, [SP]\n"        
                "BL      sub_FFEA8BDC\n"    

"loc_FFEA9360:\n"                           
                "LDR     R3, =0x7EEC4\n"    
                "MOV     R1, R4\n"          
                "LDR     R0, [R3]\n"        
                "MOV     R2, #0\n"          
                "BL      sub_FFEBD670\n" 
                "TST     R0, #1\n"          
                "BEQ     loc_FFEA91F4\n"    
                "MOV     R1, #0x3F0\n"      
                "LDR     R0, =0xFFEA8B5C\n" 
                "ADD     R1, R1, #3\n"      
                "BL      sub_FFECA7B0\n"     
                "BL      sub_FFEBEC34\n"    
                "ADD     SP, SP, #4\n"      
                "LDMFD   SP!, {R4,PC}\n"    
	);
}

/*************************************************************/
void __attribute__((naked,noinline)) exp_drv_task(){
 asm volatile(
                 "STMFD   SP!, {R4-R8,LR}\n"
                 "SUB     SP, SP, #0x20\n"
                 "ADD     R7, SP, #4\n"
                 "B       loc_ffd246dc\n"
 "loc_ffd241dc:\n"
                 "CMP     R2, #0x22\n"
                 "BNE     loc_ffd241f4\n"
                 "LDR     R0, [R12,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x88]\n"
                 "B       loc_ffd24258\n"
 "loc_ffd241f4:\n"
                 "CMP     R2, #0x1D\n"
                 "BNE     loc_ffd24208\n"
                 "MOV     R0, R12\n"
                 "BL      sub_ffd2409c\n"
                 "B       loc_ffd24248\n" 
 "loc_ffd24208:\n"
                 "CMP     R2, #0x1E\n"
                 "BNE     loc_ffd2421c\n"
                 "MOV     R0, R12\n"
                 "BL      sub_ffd240f8\n"
                 "B       loc_ffd24248\n"
 "loc_ffd2421c:\n"
                 "SUB     R3, R2, #0x1F\n"
                 "CMP     R3, #1\n"
                 "BHI     loc_ffd24234\n"
                 "MOV     R0, R12\n"
                 "BL      sub_ffd24154\n"
                 "B       loc_ffd24248\n"
 "loc_ffd24234:\n"
                 "CMP     R2, #0x21\n"
                 "BNE     loc_ffd24264\n"
                 "BL      sub_ffcea234\n"
                 "BL      sub_ffced36c\n"
                 "BL      sub_ffcec5a4\n"
 "loc_ffd24248:\n"
                 "LDR     R3, [SP,#4]\n"
                 "LDR     R0, [R3,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x88]\n"
 "loc_ffd24258:\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd1f8d4\n"
                 "B       loc_ffd246dc\n"
 "loc_ffd24264:\n"
                 "CMP     R2, #0xD\n"
                 "MOV     R8, #1\n"
                 "BNE     loc_ffd242d4\n"
                 "LDR     R1, [R12,#0x7C]\n"
                 "ADD     R1, R1, R1,LSL#1\n"
                 "ADD     R1, R12, R1,LSL#2\n"
                 "ADD     R6, SP, #0x14\n"
                 "SUB     R1, R1, #8\n"
                 "MOV     R2, #0xC\n"
                 "MOV     R0, R6\n"
                 "BL      _memcpy\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd224ac\n"
                 "LDR     R3, [SP,#4]\n"
                 "LDR     R1, [R3,#0x7C]\n"
                 "LDR     R2, [R3,#0x8C]\n"
                 "ADD     R0, R3, #4\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x88]\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd22778\n"
                 "LDR     R3, [SP,#4]\n"
                 "ADD     R0, R3, #4\n"
                 "LDR     R1, [R3,#0x7C]\n"
                 "LDR     R2, [R3,#0x94]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x90]\n"
                 "B       loc_ffd24624\n"
 "loc_ffd242d4:\n"
                 "SUB     R3, R2, #0xE\n"
                 "CMP     R3, #1\n"
                 "BHI     loc_ffd24390\n"
                 "ADD     R6, SP, #0x14\n"
                 "ADD     R5, SP, #8\n"
                 "MOV     R0, R12\n"
                 "MOV     R1, R6\n"
                 "MOV     R2, R5\n"
                 "BL      sub_ffd22868\n"
                 "MOV     R4, R0\n"
                 "CMP     R4, #5\n"
                 "CMPNE   R4, #1\n"
                 "BNE     loc_ffd24328\n"
                 "LDR     R12, [SP,#4]\n"
                 "MOV     R0, R5\n"
                 "LDR     R1, [R12,#0x7C]\n"
                 "MOV     R2, R4\n"
                 "LDR     R3, [R12,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x88]\n"
                 "B       loc_ffd24360\n"
 "loc_ffd24328:\n"
                 "CMP     R4, #6\n"
                 "CMPNE   R4, #2\n"
                 "BNE     loc_ffd24370\n"
                 "LDR     R12, [SP,#4]\n"
                 "MOV     R0, R5\n"
                 "MOV     R1, R8\n"
                 "MOV     R2, R4\n"
                 "LDR     R3, [R12,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x88]\n"
                 "MOV     R1, R6\n"
                 "LDR     R0, [SP,#4]\n"
                 "MOV     R2, R5\n"
                 "BL      sub_ffd23cfc\n"
 "loc_ffd24360:\n"
                 "MOV     R1, R4\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd24030\n"
                 "B       loc_ffd24624\n"
 "loc_ffd24370:\n"
                 "LDR     R12, [SP,#4]\n"
                 "MOV     R2, R4\n"
                 "ADD     R0, R12, #4\n"
                 "LDR     R1, [R12,#0x7C]\n"
                 "LDR     R3, [R12,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x88]\n"
                 "B       loc_ffd24624\n"
 "loc_ffd24390:\n"
                 "SUB     R3, R2, #0x19\n"
                 "CMP     R3, #1\n"
                 "BHI     loc_ffd243e8\n"
                 "LDR     R1, [R12,#0x7C]\n"
                 "ADD     R1, R1, R1,LSL#1\n"
                 "ADD     R1, R12, R1,LSL#2\n"
                 "ADD     R6, SP, #0x14\n"
                 "SUB     R1, R1, #8\n"
                 "MOV     R2, #0xC\n"
                 "MOV     R0, R6\n"
                 "BL      _memcpy\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd218a0\n"
                 "LDR     R3, [SP,#4]\n"
                 "ADD     R0, R3, #4\n"
                 "LDR     R1, [R3,#0x7C]\n"
                 "LDR     R2, [R3,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x88]\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd21c7c\n"
                 "B       loc_ffd24624\n"
 "loc_ffd243e8:\n"
                 "ADD     R6, SP, #0x14\n"
                 "ADD     R1, R12, #4\n"
                 "MOV     R2, #0xC\n"
                 "MOV     R0, R6\n"
                 "BL      memcpy\n"
                 "LDR     R12, [SP,#4]\n"
                 "LDR     R3, [R12]\n"
                 "MOV     R2, R12\n"
                 "CMP     R3, #0x1C\n"
                 "LDRLS   PC, [PC,R3,LSL#2]\n"
                 "B       loc_ffd24610\n"
                 ".long loc_ffd24488\n"
                 ".long loc_ffd24494\n"
                 ".long loc_ffd244a0\n"
                 ".long loc_ffd244a0\n"
                 ".long loc_ffd24488\n"
                 ".long loc_ffd24494\n"
                 ".long loc_ffd244a0\n"
                 ".long loc_ffd244a0\n"
                 ".long loc_ffd244c4\n"
                 ".long loc_ffd244c4\n"
                 ".long loc_ffd245e4\n"
                 ".long loc_ffd245f0\n"
                 ".long loc_ffd24600\n"
                 ".long loc_ffd24610\n"
                 ".long loc_ffd24610\n"
                 ".long loc_ffd24610\n"
                 ".long loc_ffd244ac\n"
                 ".long loc_ffd244b8\n"
                 ".long loc_ffd244d4\n"
                 ".long loc_ffd244e0\n"
                 ".long loc_ffd24518\n"
                 ".long loc_ffd24550\n"
                 ".long loc_ffd24588\n"
                 ".long loc_ffd245c0\n"
                 ".long loc_ffd245c0\n"
                 ".long loc_ffd24610\n"
                 ".long loc_ffd24610\n"
                 ".long loc_ffd245cc\n"
                 ".long loc_ffd245d8\n"
 "loc_ffd24488:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd20278\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd24494:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd2051c\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd244a0:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd20790\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd244ac:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd20a8c\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd244b8:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd20cf4\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd244c4:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd20ef4_my\n"  //---------->                 
                 "MOV     R8, #0\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd244d4:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd21054\n"
                 "B       loc_ffd2460c\n"
                 
                 
 "loc_ffd244e0:\n"
                 "LDRH    R1, [R2,#4]\n"
                 "LDR     R3, =0x2AFE0\n"
                 "STRH    R1, [SP,#0x14]\n"
                 "LDRH    R1, [R3,#6]\n"
                 "STRH    R1, [SP,#0x1A]\n"
                 "LDRH    R1, [R3,#2]\n"
                 "STRH    R1, [SP,#0x16]\n"
                 "LDRH    R3, [R3,#4]\n"
                 "STRH    R3, [SP,#0x18]\n"
                 "MOV     R0, R2\n"
                 "LDRH    R2, [R2,#0xC]\n"
                 "STRH    R2, [SP,#0x1C]\n"
                 "BL      sub_ffd2134c\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd24518:\n"
                 "MOV     R0, R2\n"
                 "LDRH    R2, [R2,#4]\n"
                 "LDR     R3, =0x2AFE0\n"
                 "STRH    R2, [SP,#0x14]\n"
                 "LDRH    R2, [R3,#8]\n"
                 "STRH    R2, [SP,#0x1C]\n"
                 "LDRH    R1, [R3,#2]\n"
                 "STRH    R1, [SP,#0x16]\n"
                 "LDRH    R2, [R3,#4]\n"
                 "STRH    R2, [SP,#0x18]\n"
                 "LDRH    R3, [R3,#6]\n"
                 "STRH    R3, [SP,#0x1A]\n"
                 "BL      sub_ffd21474\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd24550:\n"
                 "LDR     R3, =0x2AFE0\n"
                 "LDRH    R1, [R3]\n"
                 "STRH    R1, [SP,#0x14]\n"
                 "MOV     R0, R2\n"
                 "LDRH    R2, [R2,#6]\n"
                 "STRH    R2, [SP,#0x16]\n"
                 "LDRH    R2, [R3,#8]\n"
                 "STRH    R2, [SP,#0x1C]\n"
                 "LDRH    R1, [R3,#4]\n"
                 "STRH    R1, [SP,#0x18]\n"
                 "LDRH    R3, [R3,#6]\n"
                 "STRH    R3, [SP,#0x1A]\n"
                 "BL      sub_ffd21538\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd24588:\n"
                 "LDR     R3, =0x2AFE0\n"
                 "LDRH    R1, [R3,#6]\n"
                 "STRH    R1, [SP,#0x1A]\n"
                 "LDRH    R1, [R3]\n"
                 "STRH    R1, [SP,#0x14]\n"
                 "LDRH    R1, [R3,#2]\n"
                 "STRH    R1, [SP,#0x16]\n"
                 "LDRH    R3, [R3,#4]\n"
                 "STRH    R3, [SP,#0x18]\n"
                 "MOV     R0, R2\n"
                 "LDRH    R2, [R2,#0xC]\n"
                 "STRH    R2, [SP,#0x1C]\n"
                 "BL      sub_ffd215f0\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd245c0:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd216a0\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd245cc:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd21dc8\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd245d8:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd21fc4\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd245e4:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd22180\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd245f0:\n"
                 "MOV     R0, R2\n"
                 "MOV     R1, #0\n"
                 "BL      sub_ffd22368\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd24600:\n"
                 "MOV     R0, R2\n"
                 "MOV     R1, #1\n"
                 "BL      sub_ffd22368\n"
 "loc_ffd2460c:\n"
                 "LDR     R12, [SP,#4]\n"
 "loc_ffd24610:\n"
                 "ADD     R0, R12, #4\n"
                 "LDR     R1, [R12,#0x7C]\n"
                 "LDR     R2, [R12,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x88]\n"
 "loc_ffd24624:\n"
                 "CMP     R8, #1\n"
                 "BNE     loc_ffd2464c\n"
                 "LDR     R1, [SP,#4]\n"
                 "LDR     R3, [R1,#0x7C]\n"
                 "ADD     R3, R3, R3,LSL#1\n"
                 "ADD     R1, R1, R3,LSL#2\n"
                 "MOV     R0, R6\n"
                 "SUB     R1, R1, #8\n"
                 "BL      sub_ffd1ff30\n"
                 "B       loc_ffd246c8\n"
 "loc_ffd2464c:\n"
                 "LDR    R3, [SP,#4]\n"
                 "LDR    R2, [R3]\n"
                 "CMP    R2, #9\n"
                 "BNE    loc_ffd24694\n"
                 "MOV    R4, #0\n"
                 "MOV    R1, #1\n"
                 "MOV    R2, R1\n"
                 "MOV    R3, R1\n"
                 "MOV    R0, R4\n"
                 "STR    R4, [SP]\n"
                 "BL     sub_ffd1fe74\n"
                 "MOV    R1, #1\n"
                 "MOV    R0, R4\n"
                 "MOV    R2, R1\n"
                 "MOV    R3, R1\n"
                 "STR    R4, [SP]\n"
                 "BL     sub_ffd200cc\n"
                 "B      loc_ffd246c8\n"
 "loc_ffd24694:\n"
                 "MOV    R4, #1\n"
                 "MOV    R0, R4\n"
                 "MOV    R1, R4\n"
                 "MOV    R2, R4\n"
                 "MOV    R3, R4\n"
                 "STR    R4, [SP]\n"
                 "BL     sub_ffd1fe74\n"
                 "MOV    R0, R4\n"
                 "MOV    R1, R0\n"
                 "MOV    R2, R0\n"
                 "MOV    R3, R0\n"
                 "STR    R4, [SP]\n"
                 "BL     sub_ffd200cc\n"

 "loc_ffd246c8:\n"
                 "LDR    R2, =0x2B030\n"
                 "MOV    R3, #0\n"
                 "LDR    R0, [SP,#4]\n"
                 "STR    R3, [R2]\n"
                 "BL     sub_ffd1f8d4\n"

 "loc_ffd246dc:\n"
                 "LDR     R3, =0x2AFD4\n"
                 "MOV     R2, #0\n"
                 "LDR     R0, [R3]\n"
                 "MOV     R1, R7\n"
                 "BL      sub_ffebd670\n"
                 "LDR     R12, [SP,#4]\n"
                 "LDR     R2, [R12]\n"
                 "CMP     R2, #0x23\n"
                 "BNE     loc_ffd241dc\n"
                 "MOV     R0, R12\n"
                 "BL      sub_ffd1f8d4\n"
                 "LDR     R3, =0x2AFD0\n"
                 "MOV     R1, #1\n"
                 "LDR     R0, [R3]\n"
                 "BL      sub_ffebcf58\n"
                 "BL      sub_ffebec34\n" // ExitTask
                 "ADD     SP, SP, #0x20\n"
                 "LDMFD   SP!, {R4-R8,PC}\n"
 );
}

void __attribute__((naked,noinline)) sub_ffd20ef4_my(){
 asm volatile(
                 "STMFD   SP!, {R4-R6,LR}\n"
                 "LDR     R3, =0x2AFD0\n"
                 "MOV     R4, R0\n"
                 "MOV     R1, #0x3E\n"
                 "LDR     R0, [R3]\n"
                 "BL      sub_ffebd0f4\n"
                 "MOV     R1, #0\n"
                 "LDRSH   R0, [R4,#4]\n"
                 "BL      sub_ffd1fa08\n"
                 "MOV     R6, R0\n"
                 "LDRSH   R0, [R4,#6]\n"
                 "BL      sub_ffd1fbb4\n"
                 "LDRSH   R0, [R4,#8]\n"
                 "BL      sub_ffd1fc50\n"
                 "LDRSH   R0, [R4,#0xA]\n"
                 "BL      sub_ffd1fcec\n"
                 "LDRSH   R0, [R4,#0xC]\n"
                 "BL      sub_ffd1fd88\n"
                 "LDR     R3, [R4]\n"
                 "CMP     R3, #9\n"
                 "MOV     R5, R0\n"
                 "MOVEQ   R5, #0\n"
                 "MOVEQ   R6, R5\n"
                 "CMP     R6, #1\n"
                 "BNE     loc_ffd20f78\n"
                 "MOV     R2, #2\n"
                 "LDRSH   R0, [R4,#4]\n"
                 "LDR     R1, =0xFFD1F928\n"
                 "BL      sub_ffe78208\n"
                 "LDR     R2, =0x2B020\n"
                 "MOV     R3, #0\n"
                 "STR     R3, [R2]\n"
                 "B       loc_ffd20f7c\n"
 "loc_ffd20f78:\n"
                 "BL      sub_ffd1fe24\n"
 "loc_ffd20f7c:\n"
                 "STRH    R0, [R4,#4]\n"
                 "CMP     R5, #1\n"
                 "BNE     loc_ffd20f9c\n"
                 "LDRSH   R0, [R4,#0xC]\n"
                 "LDR     R1, =0xFFD1F9EC\n"
                 "MOV     R2, #0x20\n"
                 "BL      sub_ffd20218\n"
                 "B       loc_ffd20fa0\n"
 "loc_ffd20f9c:\n"
                 "BL      sub_ffd1fe64\n"
 "loc_ffd20fa0:\n"
                 "STRH    R0, [R4,#0xC]\n"
                 "LDRSH   R0, [R4,#6]\n"
                 "BL      sub_ffce9eb0_my\n"  // ------------->
                 "LDRSH   R0, [R4,#8]\n"
                 "MOV     R1, #1\n"
                 "BL      sub_ffcec164\n"
                 "ADD     R0, R4, #8\n"
                 "MOV     R1, #0\n"
                 "BL      sub_ffcec224\n"
                 "LDRSH   R0, [R4,#0xE]\n"
                 "BL      sub_ffd0e5d4\n"
                 "CMP     R6, #1\n"
                 "BNE     loc_ffd21004\n"
                 "LDR     R3, =0x2AFD0\n"
                 "MOV     R2, #0xBB0\n"
                 "LDR     R0, [R3]\n"
                 "MOV     R1, #2\n"
                 "ADD     R2, R2, #8\n"
                 "BL      sub_ffebcf48\n"
                 "TST     R0, #1\n"
                 "BEQ     loc_ffd21004\n"
                 "MOV     R1, #0x4a0\n"
                 "LDR     R0, =0xFFD1F880\n"
                 "ADD     R1, R1, #3\n"
                 "BL      sub_ffeca7b0\n"
 "loc_ffd21004:\n"
                 "CMP     R5, #1\n"
                 "LDMNEFD SP!, {R4-R6,PC}\n"
                 "LDR     R3, =0x2AFD0\n"
                 "MOV     R2, #0xBB0\n"
                 "LDR     R0, [R3]\n"
                 "MOV     R1, #0x20\n"
                 "ADD     R2, R2, #8\n"
                 "BL      sub_ffebcf48\n"
                 "TST     R0, #1\n"
                 "LDMEQFD SP!, {R4-R6,PC}\n"
                 "MOV     R1, #0x4A0\n"
                 "LDR     R0, =0xFFD1F880\n"
                 "ADD     R1, R1, #8\n"
                 "LDMFD   SP!, {R4-R6,LR}\n"
                 "B       sub_ffeca7b0\n"
 );
}

void __attribute__((naked,noinline)) sub_ffce9eb0_my(){
 asm volatile(
                 "STMFD   SP!, {R4,LR}\n"
                 "LDR     R3, =0x59FC\n"
                 "LDR     R2, [R3]\n"
                 "MOV     R1, #0x168\n"
                 "MOV     R3, R0,LSL#16\n"
                 "CMP     R2, #1\n"
                 "ADD     R1, R1, #3\n"
                 "LDR     R0, =0xFFCE96CC\n"
                 "MOV     R4, R3,ASR#16\n"
                 "BEQ     loc_FFCE9EDC\n"
                 "BL      sub_ffeca7b0\n"
 "loc_FFCE9EDC:\n"
                 "MOV     R1, #0x170\n"
                 "CMN     R4, #0xC00\n"
                 "LDR     R3, =0x11B4E\n"
                 "LDR     R0, =0xFFCE96CC\n"
                 "ADD     R1, R1, #1\n"
                 "LDREQSH R4, [R3]\n"
                 "LDRNE   R3, =0x11B4E\n"
                 "CMN     R4, #0xC00\n"
                 "STRH    R4, [R3]\n"
                 "BNE     loc_FFCE9F08\n"
                 "BL      sub_ffeca7b0\n"
 "loc_FFCE9F08:\n"
                 "MOV     R0, R4\n"
                 "BL      apex2us\n"  //---------->
                 "MOV     R4, R0\n"
                 "BL      sub_FFD764E0\n"
                 "MOV     R0, R4\n"
                 "BL      sub_FFD8D908\n"
                 "MOV     R1, #0x174\n"
                 "TST     R0, #1\n"
                 "ADD     R1, R1, #2\n"
                 "LDR     R0, =0xFFCE96CC\n"
                 "LDMEQFD SP!, {R4,PC}\n"
                 "LDMFD   SP!, {R4,LR}\n"
                 "B       sub_ffeca7b0\n"
 );
}
